// users.route.js
const Router = require("koa-router");
const { register, login, changePassword,showUserInfo,changeUserByID ,delUserByID,logout} = require("../controller/user.controller");
const { userValidator, userVerify, cryptPassword, Verifylogin } = require('../middleware/user.middleware')
const { auth } = require('../middleware/auth.middleware')
const router = new Router({ prefix: "/api/users" });


// 注册模块路径
router.post("/register", userValidator, userVerify, cryptPassword, register);
// 登录模块路径
router.post("/login", userValidator, Verifylogin, login);
// 修改密码
// router.patch("/", auth, cryptPassword, changePassword)
//获取用户信息
router.get("/userlist",showUserInfo)
// 通过ID修改用户数据
router.put("/:id",changeUserByID)
// 删除数据信息
router.delete("/:id", delUserByID)
// 退出
router.post("/logout", auth, logout)

module.exports = router;